﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ShowProjects.aspx.cs" Inherits="Actuals.ShowProjects" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
      <link href="~/Actuals.css" rel="Stylesheet" type="text/css" />

        <script type="text/javascript">


            function ShowAddProject() {
                
                var url = 'AddProject.aspx?Mode=Add';
                var result = window.showModalDialog(url, this,
                'dialogHeight:249px;dialogWidth:400px;Status:yes;Toolbars:no;Scroll:yes;Help:no;Center:yes;');
                __doPostBack('refresh', 'refresh');
            }

            function UpdateAddProject(projectId) {


                var url = 'AddProject.aspx?Mode=Edit&ProjectId=' + projectId;

                var result = window.showModalDialog(url, this, 'dialogHeight:400px;dialogWidth:400px;Status:yes;Toolbars:no;Scroll:yes;Help:no;Center:yes;');
                __doPostBack('refresh', 'refresh');
            }




            function TestCheckBox() {
                
                var Target = null;
                Target = document.getElementById('<% = this.gvResults.ClientID %>');
                if (Target == null) {
                    alert("No record is selected.Please select!");
                    return false;
                }
                var Inputs = Target.getElementsByTagName("input");
                for (var n = 0; n < Inputs.length; ++n) {
                    if (Inputs[n].type == 'checkbox' && Inputs[n].checked) {
                        return confirm("Do you want to Delete?");
                    }

                }
                alert("no record is selected.Please select!");
                return false;
            }

    </script>
<%--    <script type="text/javascript">
//<![CDATA[
        var theForm = document.forms['form1'];
        if (!theForm) {
            theForm = document.form1;
        }
        function __doPostBack(eventTarget, eventArgument) {
            if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
                theForm.__EVENTTARGET.value = eventTarget;
                theForm.__EVENTARGUMENT.value = eventArgument;
                theForm.submit();
            }
        }
//]]>
</script>--%>
</head>
<body>
    <form id="form1" runat="server">
    <center>
      <div>
            <asp:Label ID="Label2" runat="server" CssClass="ParaTitle">Projects </asp:Label>
        </div>
        
     <asp:Label ID="lblMsg" runat="server" CssClass="message"></asp:Label>
      <div id="div2" style="border: solid 1px silver; height: 520px; text-align: center;
                overflow-x: hidden; overflow-y: auto;">
                <asp:GridView ID="gvResults" AutoGenerateColumns="false" BorderColor="Black" runat="server"
                    AllowSorting="true" OnRowCommand="gvResults_OnRowCommand " >
                    <HeaderStyle BackColor="White" Font-Size="10px" ForeColor="#990000" BorderStyle="None" />
                    <RowStyle BackColor="#F7F3F7" Font-Names="Verdana" Font-Size="XX-Small" BorderStyle="None" />
                    <AlternatingRowStyle BackColor="White" Font-Names="Verdana" Font-Size="XX-Small"
                        BorderStyle="None" />
                    <Columns>
                        <asp:TemplateField HeaderStyle-Width="5%" ItemStyle-Width="5%" ItemStyle-BorderStyle="None"
                            HeaderStyle-BorderStyle="None">
                            <ItemTemplate>
                                <asp:CheckBox runat="server" ID="chkProject" AutoPostBack="false" />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField Visible="false">
                            <ItemTemplate>
                                <asp:Label ID="lblProjectId" runat="server" Text='<%# Bind("ProjectId") %>' />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="ProjectDescription">
                            <ItemTemplate>
                                <asp:Label ID="lblProjectDescription" runat="server" Text='<%#Bind("ProjectDescription") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Team">
                            <ItemTemplate>
                                <asp:Label ID="lblTeam" runat="server" Text='<%# getTeam(Eval("TeamId")) %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                     
                        <asp:TemplateField HeaderStyle-Width="5%" ItemStyle-Width="5%" ItemStyle-BorderStyle="None"
                            HeaderStyle-BorderStyle="None">
                            <ItemTemplate>
                                <asp:Button ID="btnEdit" runat="server" Text="Edit" CommandName="EditProject" 
                                CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ProjectId") %>' />
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                </asp:GridView>
            </div>

              <asp:Button ID="btnAddProject" runat="server" Text="AddProject" CssClass="button"
                OnClientClick="return ShowAddProject();" />
                <asp:Button ID="btnDelete" runat="server" CssClass="button" Text="Delete" OnClientClick="return TestCheckBox()"
            OnClick="btnDeleteProject_Click" />
            </center>
    </form>
</body>
</html>
